var dom = document.getElementsByClassName('container')[0];
var map=new BMapGL.Map(dom);
map.enableScrollWheelZoom(true);

$.ajax({
    // url
    url: 'http://127.0.0.1:8000/mapin',
    // 请求类型
    type: 'GET',
    // 响应体结果类型s
    dataType: 'json',
    // 成功的回调
    success: function(data){
        for(var i=0 ;i<data.length;i++){
            var point=[];
            for(var j=0;j<data[i].length;j++){
                point.push(new BMapGL.Point(Number(data[i][j].longitude), Number(data[i][j].latitude)))
            }
            
            var pointe = new BMapGL.Point(Number(data[i][data[i].length-1].longitude), Number(data[i][data[i].length-1].latitude));
            if(i==0){
                var center=new BMapGL.Point(Number(data[i][0].longitude), Number(data[i][0].latitude));
                map.centerAndZoom(center,13);
            }
            var marker1 = new BMapGL.Marker(pointe);
            map.addOverlay(marker1);
            var polyline = new BMapGL.Polyline(point, {
                strokeColor: 'blue',
                strokeWeight: 5,
                strokeOpacity: 0.5
            });
            map.addOverlay(polyline);
        }
    },
    // 超时时间
    timeout: 2000,
    // 失败的回调
    error: function(){
        console.log('出错了！');
    }
})